﻿using CleanArchitecture.Infrastructure.Entities.Business;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CleanArchitecture.Infrastructure.DataMapping.Business
{
    /// <summary>
    /// Represents a news mapping configuration
    /// </summary>
    public partial class NewsItemMap : NowaEntityTypeConfiguration<NewsItem>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<NewsItem> builder)
        {
            builder.ToTable("bus_news");
            builder.HasKey(newsItem => newsItem.Id);

            builder.Property(newsItem => newsItem.Title).HasMaxLength(500).IsRequired();
            builder.Property(newsitem => newsitem.FKColumnId).HasColumnName("FK_ColumnId");
            builder.Property(newsItem => newsItem.ContentOverView).HasMaxLength(2000);
            builder.Property(newsItem => newsItem.Publisher).HasMaxLength(100).IsRequired();
            builder.Property(newsitem => newsitem.Checker).HasMaxLength(100);
            builder.Property(newsitem => newsitem.WhoCanSee).IsRequired();
            builder.Property(newsitem => newsitem.AllowComments).IsRequired();
            builder.Property(newsItem => newsItem.MetaTitle).HasMaxLength(500);
            builder.Property(newsItem => newsItem.MetaKeyWords).HasMaxLength(500);
            builder.Property(newsItem => newsItem.MetaDescription).HasMaxLength(1000);
            builder.Property(newsItem => newsItem.CoverImageUrl).HasMaxLength(500);
            builder.Property(newsitem => newsitem.IsActive).IsRequired();
            builder.Property(newsitem => newsitem.IsRecommend).IsRequired();
            //builder.HasOne(newsItem => newsItem.Category)
            //    .WithMany()
            //    .HasForeignKey(newsItem => newsItem.FKCategoryId)
            //    .IsRequired();
            base.Configure(builder);
        }

        #endregion
    }
}
